#!/bin/sh
#
# Launch n stations, data sinks and data sources with associated parameters.
#
#
# (by H. Schulz 2011, edit by S. Phieler 2012)
#

NumStations=$1
Team=$2
Intervall=$3
Interface=$4
MCAddress=$5
MCPort=$6
Runtime=$7

# Base ports for data sink and source
DataSinkBasePort=11000
DataSourceBasePort=11500

if [ $# -gt 1 ] ; then
	count=1
	while [ $count -le $NumStations ] ; do
		# calculate ports for data sink and source
		Message="$count"
		DataSinkPort=`expr $DataSinkBasePort + $count`
		DatatSourcePort=`expr $DataSourceBasePort + $count`

		# launch data sink, data source and station
		./starter "$Team" "$count" "$Message" $DatatSourcePort $Intervall $DataSinkPort $Interface $MCAddress $MCPort $Runtime &

		count=`expr $count + 1`
	done
else
	echo "Usage: $0 <# of stations> <team> <data source intervall> <network-interface> <multicast-address> <multicast-port> <run-time>"
fi
exit 1